home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / batutl2.zip / WAITUNTL.ASM < prev    next >
Assembly Source File  |  1988-04-20  |  4KB  |  154 lines

  1. TITLE    WAITUNTL    12-7-84    [4-19-88]
  2. ;Toad Hall Disassembly, tweak
  3.  
  4. LF    EQU    0AH
  5. CR    EQU    0DH
  6. ;
  7. ;INITIAL VALUES :    CS:IP    0000:0100
  8. ;            SS:SP    0000:FFFF
  9. CodeSeg    SEGMENT
  10.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  11.  
  12.     ORG    80H
  13. cmdlen    db    ?,?        ;cmd line length byte at 80H
  14. hrdgt    dw    ?        ;"23" hour digits at 82H
  15. hr_sep    db    ?        ;":" separator at 84H
  16. mindgt    dw    ?        ;"59" minute digits at 85H
  17. min_sep    db    ?        ;":" separator at 87H
  18. secdgt    dw    ?        ;seconds digits at 88H
  19.  
  20. bogus    db    8 dup(?)    ;assume CR, 0 here (just a filler)
  21.  
  22. ;Toad Hall:  We're gonna use the PSP for our working data space
  23. ; (just showing off how to really scrimp on code space!)
  24.  
  25. tgtHr        db    ?
  26. tgtMin        db    ?
  27. tgtSec        db    ?
  28. currentSec    db    ?
  29. cursorPsn    dw    ?
  30.  
  31.     ORG    100H
  32.  
  33. WaitUntl    proc    near
  34. ;    JMP    SHORT    Start
  35. ;
  36. ;    DB    8,8,'  ',CR,LF
  37. ;    DB    '*** WAIT.COM ***'
  38. ;    db    LF,CR,'(c)1983 by Software Research',LF
  39. ;    DB    1AH            ;in case anyone TYPEs this...
  40.  
  41. ;Start:
  42.     cmp    cmdlen, 9        ;9 chars on PSP cmd line?
  43.     JZ    Chk_Parms        ; yep, ok so far
  44.  
  45. Die:    JMP    BadParm_Exit
  46.  
  47. Chk_Parms:
  48.     cmp    hr_sep,':'        ;hour/minute separator there?
  49.     JNZ    Die            ; nope, bad parm, exit
  50.     cmp    min_sep,':'        ;minute/second separator there?
  51.     JNZ    Die            ; nope, bad parm, exit
  52.     mov    ax,hrdgt        ;get hour digits
  53.     CALL    Conv_Int        ;process
  54.     CMP    AL,17H            ;>2300?
  55.     JA    Die            ; yep, bad parm, exit
  56.     MOV    tgtHr,AL        ; ok, save as hours
  57.     mov    ax,mindgt        ;get minute digits
  58.     CALL    Conv_Int        ;process
  59.     CMP    AL,3BH            ;> 59 minutes?
  60.     JA    Die            ; yep, bad parm, exit
  61.     MOV    tgtMin,AL        ; ok, save as minutes
  62.     mov    ax,secdgt        ;get second digits
  63.     CALL    Conv_Int        ;process
  64.     CMP    AL,3BH            ;> 59 seconds?
  65.     JA    Die            ; yep, bad parm, exit
  66.     MOV    tgtSec,AL        ; ok, save as seconds
  67.  
  68.     MOV    DX,OFFSET timeStr    ;'Time '
  69.     MOV    AH,9            ;display string
  70.     INT    21H
  71.     xor    bh,bh            ;video page 0
  72.     MOV    AH,3            ;read cursor psn
  73.     INT    10H
  74.     MOV    cursorPsn,DX        ;save cursor psn for digit repsn
  75. Check_Time:
  76.     MOV    AH,2CH            ;get DOS system time
  77.     INT    21H
  78.     CMP    DH,currentSec        ;seconds = the last second?
  79.     JZ    Check_Time        ; yep, haven't even ticked yet
  80.     MOV    currentSec,DH        ;save seconds
  81.     mov    di,dx            ;save sec/decisecs
  82.     MOV    AH,2            ;set cursor psn
  83.     MOV    DX,cursorPsn        ;saved cursor location
  84.     xor    bh,bh            ;video page 0
  85.     INT    10H
  86.     mov    dx,di            ;restore sec/decisecs
  87.     MOV    AL,CH            ;get hours
  88.     CALL    WordOut            ;process
  89.     MOV    AL,':'            ;separator
  90.     CALL    CharOut            ;display
  91.     MOV    AL,CL            ;get minutes
  92.     CALL    WordOut            ;display
  93.     MOV    AL,':'            ;separator
  94.     CALL    CharOut            ;display
  95.     MOV    AL,DH            ;get seconds
  96.     CALL    WordOut            ;display
  97.     CMP    CH,tgtHr        ;hours = target hrs?
  98.     JNZ    Check_Time        ; nope
  99.     CMP    CL,tgtMin        ;minutes = target minutes?
  100.     JNZ    Check_Time        ; nope
  101.     CMP    DH,tgtSec        ;seconds = target seconds?
  102.     JNZ    Check_Time        ; nope
  103.     mov    ax,4C00H        ;Errorlevel = 0
  104.     int    21H            ;terminate
  105.  
  106. BadParm_Exit:
  107.     MOV    DX,OFFSET invalParmStr    ;'Invalid parm'
  108.     MOV    AH,9            ;display string
  109.     INT    21H
  110.     mov    ax,4C01H        ;Errorlevel = 1
  111.     int    21H            ;terminate
  112. WaitUntl    endp
  113.  
  114. Conv_Int    proc    near
  115.     XCHG    AL,AH            ;swap
  116.     AND    AX,0F0FH        ;mask
  117.     AAD                ;convert
  118.     RET
  119. Conv_Int    endp
  120.  
  121.  
  122. WordOut    proc    near
  123.     AAM                ;convert to base 10
  124.     XCHG    AL,AH            ;swap
  125.     OR    AX,3030H        ;asciify the word
  126.     CALL    CharOut
  127.     MOV    AL,AH
  128. CharOut:
  129.     MOV    DL,AL            ;char into DL
  130.     PUSH    AX            ;save word
  131.     MOV    AH,2            ;display char
  132.     INT    21H
  133.     POP    AX            ;restore word
  134.     RET
  135. WordOut    endp
  136.  
  137. ;A bogus process, just to keep MASM happy
  138. DataStuf    proc    near
  139.  
  140. invalParmStr    DB    'Invalid Parameter [HH:MM:SS]',LF,'$'
  141.  
  142. timeStr    DB    '  Time $'
  143.  
  144. ;tgtHr    DB    0
  145. ;tgtMin    DB    0
  146. ;tgtSec    DB    0
  147. ;currentSec    DB    0
  148. ;cursorPsn    dw    0
  149.  
  150. DataStuf    endp
  151.  
  152. CodeSeg    ENDS
  153.     END    WaitUntl
  154.